package cn.lucky.springcloud.controller;

import cn.lucky.springcloud.service.HystrixOrderFeignService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author lingpeng.jiang
 * @create 2020-12-28-23:02
 */
@RestController
@RequestMapping("/consumer/hystrix/order")
public class HystrixOrderController {

    @Resource
    private HystrixOrderFeignService hystrixOrderFeignService;


    @GetMapping("/ok/{id}")
    public String hystrixPaymentInfo_OK(@PathVariable("id") Integer id){
        return hystrixOrderFeignService.hystrixPaymentInfo_OK(id);
    }

    @GetMapping("/timeout/{id}")
    public String hystrixPaymentInfo_Timeout(@PathVariable("id") Integer id){
        return hystrixOrderFeignService.hystrixPaymentInfo_Timeout(id);
    }

    @GetMapping("/circuit/{id}")
    public String circuitBreaker(@PathVariable("id") Integer id){
        return hystrixOrderFeignService.circuitBreaker(id);
    }

    /**
     * 测试负载均衡
     * @return
     */
    @GetMapping("/serverPort")
    public String getServerPort(){
        return hystrixOrderFeignService.getServerPort();
    }
}
